﻿cmake_minimum_required(VERSION 3.14)
set(Qt5_DIR D:/Qt5.12.6/5.12.6/msvc2015_64/lib/cmake/Qt5/)

project(BinocularCamera)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS ./FormFile/)
set(CMAKE_AUTOMOC ON)


#设置工程目录为当前路径
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

function(assign_source_group)
    foreach (_source IN ITEMS ${ARGN})
        if (IS_ABSOLUTE "${_source}")
            file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
        else ()
            set(_source_rel "${_source}")
        endif ()
        get_filename_component(_source_path "${_source_rel}" PATH)
        string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
        source_group("${_source_path_msvc}" FILES "${_source}")
    endforeach ()
endfunction(assign_source_group)

function(my_add_executable)
    foreach (_source IN ITEMS ${ARGN})
        assign_source_group(${_source})
    endforeach ()
    add_executable(${ARGV})
endfunction(my_add_executable)

#set(OpenCV_DIR D:/opencv/build/)
#set(OpenCV_DIR D:/opencv/build/x64/vc14/bin)
#set(OpenCV_DIR F:/software2/opencv3.4.0/x86/vc12/lib)
set(OpenCV_DIR D:/opencv/cv/opencv/build/)


find_package(OpenCV REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets  Sql Xml Charts SerialPort )


file(GLOB_RECURSE HDRS include/*.h)
file(GLOB_RECURSE SRCS src/*.cpp)

file(GLOB PREHEADER stdafx.h)

FILE(GLOB UI_FILES "FormFile/*.ui")
QT5_WRAP_UI(PROJECT_UIS_H ${UI_FILES})

include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(./thirdparty/include)
link_directories(./thirdParty/lib)
include_directories(.)


my_add_executable(${PROJECT_NAME} main.cpp ${SRCS} ${HDRS}  ${PROJECT_UIS_H} )
#ADD_LIBRARY(${PROJECT_NAME} SHARED  ${SRCS} ${HDRS})
target_link_libraries(${PROJECT_NAME}   Qt5::Core  Qt5::Xml Qt5::Sql Qt5::Widgets Qt5::Charts ${OpenCV_LIBS}       
      setupapi  CameraDevices Qt5::SerialPort  )
#控制台窗口隐掉
#Set_Target_Properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")


